﻿
using FacebookXmpp.Parse;

namespace FacebookXmpp.Stanzas
{
    internal class MessageRecieve : Stanza
    {
    	public string FromId;
        public string Text;

    	public MessageRecieve( )
    	{
    		ResponseExpectation = Expectation.Low;
    	}

    	internal override StanzaListenCriteria ListenFor
        {
            get
            {
                return new StanzaListenCriteria("message", "body");
            }
        }

        public override void ProcessResponse(MessageData recieved)
        {
            string from = recieved.Attributes["from"];

            MessageData body = recieved.Path("body") as MessageData;
            if (body == null)
                return;
            
            lock (Stream.Dashboard.Responses)
                Stream.Dashboard.AddResponse(from, (string)body.Value);            
        }
    }
}
